import { createStore } from 'vuex'
import persist from 'vuex-persistedstate'
export default createStore({
  state: {
    list: [], // 学生成绩列表
  },
  getters: {
  },
  mutations: {
    saveGread(state,val){ // 存储成绩的函数
      let num = val.gradeL*0.2+val.gradeJ*0.8; // 综合成绩
      let obj = {
        ...val,
        txt: num>=90?'优秀':num>=80?'良好':'末班'
      }
      state.list.push(obj);
    },
    update(state,val){ // 修改成绩的函数
      let num = val.value.gradeL*0.2+val.value.gradeJ*0.8; // 综合成绩
      val.value.txt = num>=90?'优秀':num>=80?'良好':'末班';
      state.list[val.i] = val.value;
    }
  },
  actions: {
  },
  modules: {
  },
  plugins:[
    new persist({
      storage: window.localStorage,
    })
  ]
})
